<?php
/**
 * 订单中心
 * User：LLW
 * Data：2020-03-25
 */

namespace app\api\controller;


use app\api\model\OrderModel;
use think\Request;
use think\response\Json;

class Order extends BaseController
{
    public function __construct(Request $request = null)
    {
        parent::__construct();
        $this->order = new OrderModel();
    }

    /**
     * 我的订单
     * @return \app\api\model\json
     */
    public function Order()
    {
        $list = $this->order->getList();
        return $list;
    }

    /**
     * 订单详情
     * @return Json
     */
    public function OrderFind()
    {
        $find = $this->order->getFind();
        return $find;
    }

    /**
     * 改变订单
     * @return Json
     */
    public function OrderDel()
    {
        $res = $this->order->getDel();
        return $res;
    }

    /**
     * 订单评价
     * @return Json
     */
    public function OrderComm()
    {
        $res = $this->order->postComm();
        return $res;
    }

    /**
     * 评价图上传
     * @return string
     */
    public function OrderUpload()
    {
        $file = $_FILES['image  '];
        $res = FileImg($file,'/uploads/evaluation/');
        if($res){
            AjaxReturn(1,'上传成功',$res);
        }else{
            AjaxReturn(-1,'error');
        }
    }

    /**
     * 加入购物车
     * @return object
     */
    public function OrderCart()
    {
        $res = $this->order->AddCart();
        return $res;
    }


    /******************************** 商品购买 ***************************************/
    /**
     * 商品结算
     * @return Json
     */
    public function OrderBuy()
    {
        $list = $this->order->getBuy();
        return $list;
    }
}